package com.zsyh.changshang.adepter;

import android.content.Context;
import android.widget.RelativeLayout;
import android.widget.TextView;



import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.zsyh.changshang.R;
import com.zsyh.changshang.bean.ZhongleiBean;

import java.util.List;

public class ErjiAdepter extends CommonAdapter<ZhongleiBean.DataBean> {


    private Context mContext;
    private int select=0;
    private List<Integer> list;
    private List<ZhongleiBean.DataBean> datas;


    public void setSelects(int select){
        this.select=select;
        notifyDataSetChanged();

    }


    public ErjiAdepter(Context context, int layoutId, List<ZhongleiBean.DataBean> datas, List<Integer> list) {
        super(context, R.layout.item_zhonglei, datas);
        mContext=context;
        this.list=list;
        this.datas=datas;
    }



    public void removeAll(){
        datas.clear();
        notifyDataSetChanged();
    }

    @Override
    public void convert(com.zsyh.changshang.adepter.ViewHolder holder, ZhongleiBean.DataBean dataBean, int position) {
        holder.setText(R.id.name, dataBean.getType_name());
        if (list.get(position)==1) {
            ((TextView) holder.getView(R.id.name)).setTextColor(mContext.getResources().getColor(R.color.white));
            holder.<RelativeLayout>getView(R.id.rebg).setBackground(mContext.getResources().getDrawable(R.drawable.xuanzexing));
        } else {
            ((TextView) holder.getView(R.id.name)).setTextColor(mContext.getResources().getColor(R.color.color_9));
            holder.<RelativeLayout>getView(R.id.rebg).setBackground(mContext.getResources().getDrawable(R.drawable.buxuan));
        }
    }

    @Override
    public void convert(ViewHolder holder, ZhongleiBean.DataBean dataBean, int position) {
        holder.setText(R.id.name, dataBean.getType_name());
        if (list.get(position)==1) {
            ((TextView) holder.getView(R.id.name)).setTextColor(mContext.getResources().getColor(R.color.white));
            holder.<RelativeLayout>getView(R.id.rebg).setBackground(mContext.getResources().getDrawable(R.drawable.xuanzexing));
        } else {
            ((TextView) holder.getView(R.id.name)).setTextColor(mContext.getResources().getColor(R.color.color_9));
            holder.<RelativeLayout>getView(R.id.rebg).setBackground(mContext.getResources().getDrawable(R.drawable.buxuan));
        }
    }


}
